package com.ynkbny.web.controller;

import com.ynkbny.base.PageResult;
import com.ynkbny.domain.Gaugereplacecfg;
import com.ynkbny.service.GaugereplacecfgService;
import com.ynkbny.util.Res;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: GaugereplacecfgController
 * Package: com.ynkbny.web.controller
 * Description:
 *
 * @Author 小雄
 * @Create 2024/5/24 15:01
 * @Version 1.0
 */
@Api(tags = "用能单位计量器具更换记录接口")
@RestController
@RequestMapping("/gaugereplacecfg")
public class GaugereplacecfgController {

    @Autowired
    private GaugereplacecfgService gaugereplacecfgService;

    @ApiOperation("分页查询")
    @GetMapping("/pageList")
    public Res<PageResult<Gaugereplacecfg>> pageList(@RequestParam(name = "pageNum", required = false, defaultValue = "1") long pageNum,
                                                     @RequestParam(name = "pageSize", required = false, defaultValue = "15") long pageSize,
                                                     @RequestParam(name = "condition", required = false) String conditionJson) {
        PageResult<Gaugereplacecfg> enterprisePageResult = gaugereplacecfgService.pageList(pageNum,pageSize,conditionJson);
        return Res.ok(enterprisePageResult);
    }

    @ApiOperation("添加接口")
    @PostMapping("/add")
    public Res add(@RequestBody Gaugereplacecfg gaugereplacecfg){
        return gaugereplacecfgService.add(gaugereplacecfg)?Res.ok("添加成功！"):Res.fail("添加失败！");
    }

    @ApiOperation("修改接口")
    @PostMapping("/edit")
    public Res edit(@RequestBody Gaugereplacecfg gaugereplacecfg){
        return gaugereplacecfgService.update(gaugereplacecfg)?Res.ok("修改成功！"):Res.fail("修改失败！");
    }

    @ApiOperation("删除接口")
    @DeleteMapping("/del")
    public Res del(@RequestBody Gaugereplacecfg gaugereplacecfg) {
        return gaugereplacecfgService.delete(gaugereplacecfg)?Res.ok("删除成功！"):Res.fail("删除失败");
    }
}
